package com.imooc.mapping.course3;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @Author Tim
 * @Description:
 * @Version 1.0
 */
public class DateMapper {
    private static final String PATTERN = "yyyy-MM-dd HH:mm:ss";

    public String asString(LocalDateTime dateTime){
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(PATTERN);
        return dateTimeFormatter.format(dateTime);
    }

    public LocalDateTime asDate(String date){
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(PATTERN);
        return LocalDateTime.parse(date, dateTimeFormatter);
    }
}
